package com.augurit.gzcgwsp.ywcmn.convert;

import java.util.ArrayList;
import java.util.List;

import org.dozer.DozerBeanMapper;

import com.augurit.gzcgwsp.ywcmn.entity.YwComSjcllist;
import com.augurit.gzcgwsp.ywcmn.entity.YwComSjcllistOther;
import com.augurit.gzcgwsp.ywcmn.web.form.YwComSjcllistForm;
import com.augurit.gzcgwsp.ywcmn.web.form.YwComSjcllistOtherForm;

public class YwComSjcllistConvertor {
	public static YwComSjcllistForm convertVoToForm(YwComSjcllist entity) {
		if (entity == null) return null;
		
		return new DozerBeanMapper().map(entity, YwComSjcllistForm.class);
	}
	
	public static void convertFormToVo(YwComSjcllistForm form, YwComSjcllist entity) {
		if (form == null) return;
		if (entity == null) entity = new YwComSjcllist();
		
		new DozerBeanMapper().map(form, entity);
	}
	
	public static List<YwComSjcllistForm> convertVoListToFormList(List<YwComSjcllist> ywComSjcllistList) {
        List<YwComSjcllistForm> ywComSjcllistFormList = new ArrayList<YwComSjcllistForm>();
		if(ywComSjcllistList != null && ywComSjcllistList.size() > 0) {
			for(int i=0; i<ywComSjcllistList.size(); i++) {
				ywComSjcllistFormList.add(convertVoToForm(ywComSjcllistList.get(i)));
			}
		}
		return ywComSjcllistFormList;
	}
	
	public static List<YwComSjcllist> convertFormListToVoList(List<YwComSjcllistForm> ywComSjcllistFormList) {
		if(ywComSjcllistFormList != null && ywComSjcllistFormList.size() > 0) {
			List<YwComSjcllist> ywComSjcllistList = new ArrayList<YwComSjcllist>();
			for(int i=0; i<ywComSjcllistFormList.size(); i++) {
				YwComSjcllist ywComSjcllist = new YwComSjcllist();
				convertFormToVo(ywComSjcllistFormList.get(i), ywComSjcllist);
				ywComSjcllistList.add(ywComSjcllist);
			}
			return ywComSjcllistList;
		}
		return null;
	}
	public static List<YwComSjcllistForm> convertOtherSjcllistFormListToSjcllistFormList(List<YwComSjcllistOtherForm> otherSjcllistOtherFormList) {
        List<YwComSjcllistForm> ywComSjcllistFormList = new ArrayList<YwComSjcllistForm>();
		if(otherSjcllistOtherFormList != null && otherSjcllistOtherFormList.size() > 0) {
			for(int i=0; i<otherSjcllistOtherFormList.size(); i++) {
				ywComSjcllistFormList.add(convertSjcllistOtherFormToSjcllistForm(otherSjcllistOtherFormList.get(i)));
			}
		}
		return ywComSjcllistFormList;
	}
	public static YwComSjcllistForm convertSjcllistOtherFormToSjcllistForm(YwComSjcllistOtherForm ywComSjcllistOtherForm) {
		if (ywComSjcllistOtherForm == null) return null;
		ywComSjcllistOtherForm.setOtherFlag("Y");
		return new DozerBeanMapper().map(ywComSjcllistOtherForm, YwComSjcllistForm.class);
	}
}